package cn.itcast.health.commons.utils;

import org.springframework.context.support.ClassPathXmlApplicationContext;
import org.springframework.data.redis.core.RedisTemplate;

import java.util.ArrayList;
import java.util.List;

public class RedisTemUtil {

    private static ClassPathXmlApplicationContext applicationContext;
    private static RedisTemplate<String, Object> redisTemplate;

    static {

        applicationContext = new ClassPathXmlApplicationContext("applicationContext-redis.xml");
        redisTemplate = applicationContext.getBean("redisTemplate", RedisTemplate.class);

    }

    /**
     * 将数据放入set缓存
     * @param key 键
     * @param
     * @return
     */

    //存list集合对象
    public static void setList(String key,  Object setlist) {
        redisTemplate.opsForValue().set(key,setlist);
    }

    //取list集合对象
    public static List getList(String key) {
        return (List) redisTemplate.opsForValue().get(key);
    }

}
